﻿using System.Web;
using ECommerce.DAL;
using System.Data.SqlClient;
using System.Data;
using System.Collections;
using System;
using eShop.Model;
using eShop.DataAccess;
namespace Entity
{
    public class PartnerCategories
    {
        public Int32 PartnerCatId { get; set; }
        public Int32 PartnerId { get; set; }
        public Int32 CategoryId { get; set; }
    }

    public partial class TblPartnerCategories
    {
        public static CustomCollection<Category> GetAllTblPartnerCategoryByPartnerId(int partnerId)
        {

            // Execute SQL Command
            SqlCommand sqlCmd = new SqlCommand();
            AddParameterToSqlCmd(sqlCmd, "@PartnerId", SqlDbType.Int, 4, ParameterDirection.Input, partnerId);
            SetCommandType(sqlCmd, CommandType.StoredProcedure, "spr_TblProductCategory_GetTblProductCategoryByPartnerId");

            GenerateCollectionFromReader test = new GenerateCollectionFromReader(CategoryDAO.GenerateTblProductCategoryCollectionFromReader);
            CustomCollection<Category> objCollection = ((CustomCollection<Category>)ExecuteReaderCmd(sqlCmd, test));
            return objCollection;
        }
        public static CustomCollection<PartnerCategories> GetAllTblPartnerCategoryByCategoryId(Int32 catId)
        {

            // Execute SQL Command
            SqlCommand sqlCmd = new SqlCommand();
            AddParameterToSqlCmd(sqlCmd, "@CategoryId", SqlDbType.Int, 0, ParameterDirection.Input, catId);
            SetCommandType(sqlCmd, CommandType.StoredProcedure, "spr_TblPartnerCategory_GetAllTblPartnerCategoryByCategoryId");

            GenerateCollectionFromReader test = new GenerateCollectionFromReader(CategoryDAO.GenerateTblProductCategoryCollectionFromReader);
            CustomCollection<PartnerCategories> objCollection = ((CustomCollection<PartnerCategories>)ExecuteReaderCmd(sqlCmd, test));
            return objCollection;
        }
        [System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Update, true)]
        public static bool DeleteTblPartnerCategoriesByCategoryId
        (
            Int32 categoryId
        )
        {
            
            // Execute SQL Command
            SqlCommand sqlCmd = new SqlCommand();
            AddParameterToSqlCmd(sqlCmd, "@ReturnValue", SqlDbType.Int, 0, ParameterDirection.ReturnValue, null);
            AddParameterToSqlCmd(sqlCmd, "@CategoryId", SqlDbType.Int, 0, ParameterDirection.Input, categoryId);
            SetCommandType(sqlCmd, CommandType.StoredProcedure, "spr_TblPartnerCategories_DeleteTblPartnerCategoriesByCategoryId");
            ExecuteScalarCmd(sqlCmd);
            int returnValue = (int)sqlCmd.Parameters["@ReturnValue"].Value;
            return (returnValue == 0 ? false : true);

        }
    }
}